extends ../templates/main.jade

block title
  | Braces &amp; Semicolons | Language Criticism | xigoi

block content
  h1 Braces Criticism
  p There are, in general, three common ways to delimit code blocks: braces, end-keywords and indentation. When we write pseudocode on paper, we tend to almost always use indentation — it provides an easy visual cue and takes the least effort to write. So why do so many programmers insist on using braces for this purpose, which make code much harder to visually parse? Here are some commonly given reasons with my responses:
  dl.qa
    dt Pasting code from the internet messes up the indentation and it's tedious to fix it.
    dd Are you coding in Windows Notepad?
    dt A changed indent can cause the code to behave differently.
    dd When this happens, you'll clearly see it. On the other hand, a misplaced brace might go unnoticed and the indentation will give you a false sense of the code being correct.
    dt I have auto-indent, so the indentation will always match the braces.
    dd That's cool. You'll still get slowed down by having to visually process them.
    dt I don't think invisible characters should change the meaning of code.
    dd
      | Firstly, indentation is followed by visible characters, which makes you able to clearly see it. Secondly, by this argument, you could also argue that 
      code publicstaticvoidmain
      |  should be equivalent to 
      code public static void main
      |  — we're just ignoring “invisible” characters, no?
    dt Mixing spaces and tabs is going to create a mess.
    dd See the answer to the first question.
  h1 Semicolons Criticism
  p
    | A very popular feature in programming languages, especially those derived from 
    a(href='c.html') C
    | , is requiring a semicolon after every statement. Why is this necessary if you're already separating statements by newlines? It just adds one more character you need to type; and more importantly, a lot more characters that you have to visually process, but that don't contribute in any way to the logic of the code (the term for this is 
    dfn syntactic noise
    | ). There's a lot of languages that do completely fine without them: Python, Ruby, Lua, Nim, Go, Haskell, etc. And JavaScript shows that even in a language that uses semicolons, they can be inferred pretty well. Also note that Lua doesn't actually care about newlines, its syntax is made in a way that a statement always ends unambiguously.
